﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace Andrewl.XnaHelpers.IO
{
    public static class FileWriter
    {
        //StreamWriter so we can write to files
        public static StreamWriter fileWriter;
        //Accessor for our StreamWriter
        public static StreamWriter Writer
        { get { return fileWriter; } }
        //Set the path so we know where to write
        public static void SetPath(string path)
        {
            fileWriter = new StreamWriter(path);
        }
        //Set the path to the selected storage path
        public static void SetPath()
        {
            fileWriter = new StreamWriter(XnaHelpers.storage.Path);
        }
        /// <summary>
        /// Write 'contents' on a new line in our current file
        /// </summary>
        /// <param name="contents"></param>
        public static void WriteLine(string contents)
        {
            fileWriter.WriteLine(contents);
        }
        /// <summary>
        /// Write 'content's to the file
        /// </summary>
        /// <param name="contents"></param>
        public static void Write(string contents)
        {
            fileWriter.Write(contents);
        }
        /// <summary>
        /// Write everything to the file and release it from our control
        /// </summary>
        public static void Flush()
        {
            fileWriter.Flush();
            fileWriter.Dispose();
        }
    }
}
